package com.sdleyou.treepro.manager.api.card;

import com.sdleyou.treepro.common.model.dto.TreeDTO;
import com.sdleyou.treepro.common.model.utils.ResultVOUtil;
import com.sdleyou.treepro.common.model.vo.ResultVO;
import com.sdleyou.treepro.common.service.CardManager;
import com.sdleyou.treepro.common.service.TreeManager;
import com.sdleyou.treepro.system.version.ApiVersion;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.validation.constraints.NotEmpty;

/**
 * 卡片信息控制器
 */
@RestController
@RequestMapping("/api")
public class ManagerCardController {
    @Autowired
    private CardManager cardManager;

    /**
     * 创建卡片信息
     */
    @ApiVersion(1)
    @PostMapping("/{version}/manager/card")
    public ResultVO createCard(@RequestParam(name = "img") @NotEmpty(message = "图片不能为空")String img) {
        cardManager.createCard(img);
        return ResultVOUtil.success();
    }

    /**
     * 修改卡片信息
     */
    @ApiVersion(1)
    @PutMapping("/{version}/manager/card/{card_id}")
    public ResultVO updateCard(@RequestParam(name = "card_id") @NotEmpty(message = "id不能为空")String cardId,
                               @RequestParam(name = "img") @NotEmpty(message = "图片不能为空")String img) {
        cardManager.updateCard(cardId, img);
        return ResultVOUtil.success();
    }
}
